package com.isunland.managesystem.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BasePagerActivity;
import com.isunland.managesystem.entity.LeaseMainList;
import com.isunland.managesystem.entity.PayAndBackParams;
import java.util.UUID;

/**
 * 对象功能: 预约下单pager页.
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2016/12/12 19:36
 */

public class LeaseOrderPagerActivity extends BasePagerActivity {
  private static final String EXTRA_ITEM =
      LeaseOrderPagerActivity.class.getSimpleName() + ".EXTRA_ITEM";
  private String mId;
  private LeaseMainList mItem;

  public static void newInstance(Fragment fragment, Activity context, LeaseMainList item,
      int requestCode) {
    if (fragment == null || context == null) return;
    Intent i = new Intent(context, LeaseOrderPagerActivity.class);
    i.putExtra(EXTRA_ITEM, item);
    fragment.startActivityForResult(i, requestCode);
  }

  @Override protected void onCreate(Bundle arg0) {
    mItem = (LeaseMainList) getIntent().getSerializableExtra(EXTRA_ITEM);
    if (mItem != null) mId = mItem.getId();
    //if (mItem !=null) mId= "5fec0274-c371-11e6-8ba4-b82a72dbffec";
    super.onCreate(arg0);
  }

  @Override protected Fragment createFragmentOne() {
    return LeaseOrderDetailFragment.newInstance(mItem);
  }

  @Override protected Fragment createFragmentTwo() {
    PayAndBackParams params = new PayAndBackParams();
    params.setId(UUID.randomUUID().toString());
    params.setMainId(mId);
    params.setPayMuch(String.valueOf(0));
    params.setEditable(true);
    params.setMoneyType(PayAndBackParams.MONEY_TYPE_LEASE_FEE);
    params.setBookOrderNo(mItem != null ? mItem.getOrderNo() : "");
    params.setOrderType(PayAndBackParams.ORDER_TYPE_LEASE);
    return PayAndBackFragment.newInstance(params, new PayAndBackFragment());
  }

  @Override public Fragment createFragmentThree() {
    return LocaleWorkQueryCountDiaryListFragment.newInstance(mId);
  }

  @Override protected int[] createTitle() {
    return new int[] { R.string.orderDetail, R.string.payAndRefund, R.string.operationDiary };
  }
}
